/*****************************************************************************
* Keppe Messenger (KMP) Keppe Project-Team User Messaging System
* Copyright (C) 2013-2014 Keppe Project-Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/

#ifndef FRMLOGIN_H
#define FRMLOGIN_H

#include <QMainWindow>
#include <QCloseEvent>
#include <QListWidgetItem>
#include <QSystemTrayIcon>

namespace Ui {
class frmLogin;
}

class frmLogin : public QMainWindow
{
    Q_OBJECT
    
public:
    explicit frmLogin(QWidget *parent = 0);
    void addContactOverMenu(QObject* menu);
    void addContactItem(QString username);
    int addUserContact(QString username);
    int delUserContact(QString username);
    int sendMessage(QString username, QString message);
    int setUserPassword(QString oldpassword, QString newpassword);
    int setUserNick(QString nick);
    int setUserMessageState(QString message);
    bool isConnectedWithServer();
    void removeMe(QString username);
    void openChatWindow(QString username, QString nickname, QString userstate, bool minimized=false);
    void loginUserDataFromLines(bool showErrors);
    void updateWelcomeLabel(QString nick);
    void updateFriendRequests();
    void updateFriendRequestList(QString toAdd, QString toRemove);
    void notification(QString text, QString method);
    QByteArray fromMessage(QString message);
    QString toAccountName(QByteArray account);
    QString getIconPathForOnlineState(int id);
    QString getOnlineStateStringFromID(int id);
    ~frmLogin();

public slots:
    void playChatIn();
    void setStateOnline();
    void setStateAway();
    void setStateBusy();
    void setStateNotjust();
    void setStateShowoffline();
    void logoutUser();
    void logoutUserWithRemoveAutologin();
    void addContactShow();
    void editProfileShow();
    void changePasswordShow();
    void removeContactShow();
    
private slots:
    void on_cmdLogin_clicked();
    void on_timerFR_tick();
    void on_timerSS_tick();
    void on_timerOA_tick();
    void on_timerLC_tick();
    void on_lwContacts_itemDoubleClicked(QListWidgetItem *item);
    void closeEvent(QCloseEvent *event);
    void openLoginWindowNormal();
    void endKM();
    void on_cmdClose_clicked();
    void on_lwContacts_itemClicked(QListWidgetItem *item);
    void on_cmdFix_clicked();
    void on_labWelcomeNick_linkActivated(const QString &link);
    void on_lwContacts_mouseMove(QMouseEvent *);

private:
    Ui::frmLogin *ui;
    int globY;
};

#endif // FRMLOGIN_H
